package com.jilin.library.controller;

import com.jilin.library.entity.PurchaseRecord;
import com.jilin.library.service.PurchaseRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/purchases")
@CrossOrigin
public class PurchaseRecordController {
    @Autowired
    private PurchaseRecordService purchaseRecordService;
    
    @GetMapping
    public List<PurchaseRecord> getAllPurchases() {
        return purchaseRecordService.findAll();
    }
    
    @PostMapping
    public PurchaseRecord addPurchase(@RequestBody PurchaseRecord record) {
        return purchaseRecordService.addPurchase(record);
    }
} 